<%--
  Created by IntelliJ IDEA.
  User: xxlc
  Date: 2019/5/21
  Time: 13:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>进货汇总</title>
    <jsp:include page="/common/backend_common.jsp"/>
    <%--<jsp:include page="/common/page.jsp"/>--%>
    <script src="https://cdn.bootcss.com/moment.js/2.18.1/moment-with-locales.min.js"></script>
    <link href="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css"
          rel="stylesheet"/>
    <link rel="stylesheet" href="/assets1/css/jquery.gritter.css" />
    <script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="/assets/js/FileSaver.min.js"></script>
    <script type="text/javascript" src="/assets/js/tableExport.js"></script>
   <style type="text/css">
        .btn:focus,
        .btn:active:focus,
        .btn.active:focus,
        .btn.focus,
        .btn:active.focus,
        .btn.active.focus {
            outline: none;
        }

        .table-bordered {
            border: 1px solid #428bca;
        }
    </style>
    <link rel="stylesheet" href="/assets1/css/ace.min11.css" />
    <link rel="stylesheet" href="/assets1/css/font-awesome.min6.css" />
    <script type="text/javascript" src="/assets1/js/ace.min.js"></script>
    <script type="text/javascript" src="/assets1/js/ace-elements.min.js"></script>
</head>
<body style="background-color: white">
<input id="gritter-light" checked="" type="checkbox" class="ace ace-switch ace-switch-5"/>

<div class="page-header" style="margin-top: 0px">
    <h1>
        进货统计与分析
        <small>
            <i class="ace-icon fa fa-angle-double-right"></i>
            查询与统计进货信息汇总
        </small>
    </h1>
</div>
<div class="main-content-inner">
<div class="row" style="margin:0 auto; width: 700px">
    <label>
        <input type="hidden" name="jbzCode" id="jbzCode"
               value="${sessionScope.user.jbzCode}"/>
    </label>
    <div class='input-group date' id='datetimepicker1' style="width: 200px; float: left">
        <input id="search-from" name="fromTime" class="form-control input-sm"
               placeholder="开始时间" aria-controls="dynamic-table"/>
        <span class="input-group-addon"><span
                class="glyphicon glyphicon-calendar"></span></span>
    </div><div style="float: left">
    &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;~ &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
</div>

    <div class='input-group date' id='datetimepicker2' style="width: 200px; float: left">
        <input id="search-to" name="toTime" class="form-control input-sm"
               placeholder="结束时间" aria-controls="dynamic-table"/>
        <span class="input-group-addon"><span
                class="glyphicon glyphicon-calendar"></span></span>
    </div>
    &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
    <button class="btn btn-info btn-sm fa fa-check research"  type="button">
        查询&nbsp;
    </button>
</div>
<div class="hr hr-dotted"></div>

<div class="row">
    <%--供货单位--%>
    <div class="col-sm-6">
        <div class="widget-box transparent">
            <div class="widget-header widget-header-flat">
                <h4 class="lighter">
                    <i class="icon-bar-chart"></i>
                    按供货单位
                </h4>

                <div class="widget-toolbar">
                    <a href="#" data-action="collapse">
                        <i class="icon-chevron-up"></i>
                    </a>
                </div>
            </div>

            <div class="widget-body">
                <div class="widget-main no-padding">
                    <table class="table table-bordered table-customer table-striped">
                        <thead class="thin-border-bottom">
                        <tr>
                            <th>
                                <i class="icon-group blue"></i>
                                生产单位
                            </th>

                            <th>
                                <i class="icon-caret-right blue"></i>
                                货物名称
                            </th>
                            <th>
                                <i class="icon-caret-right blue"></i>
                                货物规格
                            </th>

                            <th class="hidden-480">
                                <i class="icon-caret-right blue"></i>
                                车次
                            </th>

                            <th class="hidden-480">
                                <i class="icon-caret-right blue"></i>
                                总重量
                            </th>
                        </tr>
                        </thead>

                        <tbody id="SendProUnitList"></tbody>
                    </table>
                    <div class="row" id="SOCPage"></div>
                </div><!-- /widget-main -->

            </div><!-- /widget-body -->

        </div><!-- /widget-box -->
    </div>
    <%--供货单位--%>
    <%--车牌号--%>
    <div class="col-sm-6">
        <div class="widget-box transparent">
            <div class="widget-header widget-header-flat">
                <h4 class="lighter orange">
                    <i class="icon-bar-chart orange"></i>
                    按车牌
                </h4>

                <div class="widget-toolbar">
                    <a href="#" data-action="collapse">
                        <i class="icon-chevron-up"></i>
                    </a>
                </div>
            </div>

            <div class="widget-body">
                <div class="widget-main no-padding">
                    <table class="table table-bordered table-striped">
                        <thead class="thin-border-bottom">
                        <tr>
                            <th>
                                <i class="icon-truck orange"></i>
                                车号
                            </th>

                            <th>
                                <i class="icon-caret-right blue"></i>
                                货物名称
                            </th>

                            <th class="hidden-480">
                                <i class="icon-caret-right blue"></i>
                                车次
                            </th>
                            <th class="hidden-480">
                                <i class="icon-caret-right blue"></i>
                                总重量
                            </th>
                        </tr>
                        </thead>

                        <tbody id="WeighTruckList"></tbody>
                    </table>
                    <div class="row" id="WeighTruckPage"></div>
                </div><!-- /widget-main -->
            </div><!-- /widget-body -->
        </div><!-- /widget-box -->
    </div>
    <%--车牌号--%>
</div>


<div class="hr hr32 hr-dotted"></div>

<div class="row">
    <%--存放位置--%>
    <div class="col-sm-6">
            <div class="widget-box transparent">
                <div class="widget-header widget-header-flat">
                    <h4 class="lighter green">
                        <i class="icon-bar-chart green"></i>
                        按存放位置
                    </h4>

                    <div class="widget-toolbar">
                        <a href="#" data-action="collapse">
                            <i class="icon-chevron-up"></i>
                        </a>
                    </div>
                </div>

                <div class="widget-body">
                    <div class="widget-main no-padding">
                        <table class="table table-bordered table-striped">
                            <thead class="thin-border-bottom">
                            <tr>
                                <th>
                                    <i class="icon-caret-right blue"></i>
                                    存货位置
                                </th>

                                <th>
                                    <i class="icon-caret-right blue"></i>
                                    货物名称
                                </th>
                                <th>
                                    <i class="icon-caret-right blue"></i>
                                    货物规格
                                </th>

                                <th class="hidden-480">
                                    <i class="icon-caret-right blue"></i>
                                    总重量
                                </th>
                            </tr>
                            </thead>

                            <tbody id="WeighStorageList"></tbody>
                        </table>
                        <div class="row" id="WCStoragePage"></div>
                    </div><!-- /widget-main -->
                </div><!-- /widget-body -->

            </div><!-- /widget-box -->
        </div>
    <%--存放位置--%>
    <%--货物名称--%>
    <div class="col-sm-6">
            <div class="widget-box transparent">
                <div class="widget-header widget-header-flat">
                    <h4 class="lighter red">
                        <i class="icon-bar-chart red"></i>
                        按货物名称
                    </h4>

                    <div class="widget-toolbar">
                        <a href="#" data-action="collapse">
                            <i class="icon-chevron-up"></i>
                        </a>
                    </div>
                </div>

                <div class="widget-body">
                    <div class="widget-main no-padding">
                        <table class="table table-bordered table-striped">
                            <thead class="thin-border-bottom">
                            <tr>
                                <th>
                                    <i class="icon-caret-right blue"></i>
                                    货物名称
                                </th>

                                <th>
                                    <i class="icon-caret-right blue"></i>
                                    规格型号
                                </th>

                                <th>
                                    <i class="icon-caret-right blue"></i>
                                    总重量
                                </th>
                            </tr>
                            </thead>

                            <tbody id="WeighNameList"></tbody>
                        </table>
                        <div class="row" id="WCNamePage"></div>
                    </div><!-- /widget-main -->
                </div><!-- /widget-body -->
            </div><!-- /widget-box -->
        </div>
    <%--货物名称--%>
    </div>

<div class="hr hr32 hr-dotted"></div>


</div>

<!-- inline scripts related to this page -->
<script src="/assets1/js/jquery.easy-pie-chart.min.js"></script>
<script src="/assets1/js/jquery.sparkline.min.js"></script>
<script src="/assets1/js/jquery.gritter.min.js"></script>

<script id="SendProUnitListTemplate" type="x-tmpl-mustache">
{{#SendProUnitList}}
   <tr>
      <td><i class="icon-user blue"></i>{{provideunit}}</td>
      <td>{{goodsname}}</td>
      <td>{{goodsspec}}</td>
      <td><small><b class="blue">{{sumnub}}</b></small></td>
      <td class="hidden-480">
      <span class="label label-primary">{{w}}</span>
      </td>
   </tr>
{{/SendProUnitList}}
</script>

<script id="WeighTruckListTemplate" type="x-tmpl-mustache">
{{#WeighTruckList}}
   <tr>
      <td><i class="icon-truck orange"></i>{{truckid}}</td>
      <td>{{goodsname}}</td>
      <td><small><b class="orange">{{sumnub}}</b></small></td>
      <td class="hidden-480">
      <span class="label label-warning">{{w}}</span>
      </td>
   </tr>
{{/WeighTruckList}}

</script>

<script id="WeighStorageListTemplate" type="x-tmpl-mustache">
{{#WeighStorageList}}
   <tr>
      <td>{{storage}}</td>
      <td>{{goodsname}}</td>
      <td>{{goodsspec}}</td>
      <td class="hidden-480">
      <span class="label label-success">{{w}}</span>
      </td>
   </tr>
{{/WeighStorageList}}

</script>

<script id="WeighNameListTemplate" type="x-tmpl-mustache">
{{#WeighNameList}}
   <tr>
      <td>{{goodsname}}</td>
      <td>{{goodsspec}}</td>
      <td class="hidden-480">
      <span class="label label-danger">{{w}}</span>
      </td>
   </tr>
{{/WeighNameList}}

</script>

<script id="paginateTemplate" type="x-tmpl-mustache">
<div class="col-xs-4">
    <div class="dataTables_info" id="dynamic-table_info" role="status" aria-live="polite">
        总共 {{total}} 中的 {{from}} ~ {{to}}
    </div>
</div>

<div class="col-xs-8">
    <div class="dataTables_paginate paging_simple_numbers" id="dynamic-table_paginate">
        <ul class="pagination">
            <li class="paginate_button previous {{^firstUrl}}disabled{{/firstUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="1" data-url="{{firstUrl}}" class="page-action">首页</a>
            </li>
            <li class="paginate_button {{^beforeUrl}}disabled{{/beforeUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="{{beforePageNo}}" data-url="{{beforeUrl}}" class="page-action"><<</a>
            </li>
            <li class="paginate_button active" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-id="{{pageNo}}" >第{{pageNo}}页</a>
                <input type="hidden" class="pageNo" value="{{pageNo}}" />
            </li>
            <li class="paginate_button {{^nextUrl}}disabled{{/nextUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="{{nextPageNo}}" data-url="{{nextUrl}}" class="page-action">>></a>
            </li>
            <li class="paginate_button next {{^lastUrl}}disabled{{/lastUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="{{maxPageNo}}" data-url="{{lastUrl}}" class="page-action">尾页</a>
            </li>
        </ul>
    </div>
</div>

</script>

<script id="paginateTemplate1" type="x-tmpl-mustache">
<div class="col-xs-4">
    <div class="dataTables_info" id="dynamic-table_info" role="status" aria-live="polite">
        总共 {{total}} 中的 {{from}} ~ {{to}}
    </div>
</div>

<div class="col-xs-8">
    <div class="dataTables_paginate paging_simple_numbers" id="dynamic-table_paginate">
        <ul class="pagination">
            <li class="paginate_button previous {{^firstUrl}}disabled{{/firstUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="1" data-url="{{firstUrl}}" class="page-action1">首页</a>
            </li>
            <li class="paginate_button {{^beforeUrl}}disabled{{/beforeUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="{{beforePageNo}}" data-url="{{beforeUrl}}" class="page-action1"><<</a>
            </li>
            <li class="paginate_button active" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-id="{{pageNo}}" >第{{pageNo}}页</a>
                <input type="hidden" class="pageNo" value="{{pageNo}}" />
            </li>
            <li class="paginate_button {{^nextUrl}}disabled{{/nextUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="{{nextPageNo}}" data-url="{{nextUrl}}" class="page-action1">>></a>
            </li>
            <li class="paginate_button next {{^lastUrl}}disabled{{/lastUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="{{maxPageNo}}" data-url="{{lastUrl}}" class="page-action1">尾页</a>
            </li>
        </ul>
    </div>
</div>

</script>

<script id="paginateTemplate2" type="x-tmpl-mustache">
<div class="col-xs-4">
    <div class="dataTables_info" id="dynamic-table_info" role="status" aria-live="polite">
        总共 {{total}} 中的 {{from}} ~ {{to}}
    </div>
</div>

<div class="col-xs-8">
    <div class="dataTables_paginate paging_simple_numbers" id="dynamic-table_paginate">
        <ul class="pagination">
            <li class="paginate_button previous {{^firstUrl}}disabled{{/firstUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="1" data-url="{{firstUrl}}" class="page-action2">首页</a>
            </li>
            <li class="paginate_button {{^beforeUrl}}disabled{{/beforeUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="{{beforePageNo}}" data-url="{{beforeUrl}}" class="page-action2"><<</a>
            </li>
            <li class="paginate_button active" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-id="{{pageNo}}" >第{{pageNo}}页</a>
                <input type="hidden" class="pageNo" value="{{pageNo}}" />
            </li>
            <li class="paginate_button {{^nextUrl}}disabled{{/nextUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="{{nextPageNo}}" data-url="{{nextUrl}}" class="page-action2">>></a>
            </li>
            <li class="paginate_button next {{^lastUrl}}disabled{{/lastUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="{{maxPageNo}}" data-url="{{lastUrl}}" class="page-action2">尾页</a>
            </li>
        </ul>
    </div>
</div>

</script>

<script id="paginateTemplate3" type="x-tmpl-mustache">
<div class="col-xs-4">
    <div class="dataTables_info" id="dynamic-table_info" role="status" aria-live="polite">
        总共 {{total}} 中的 {{from}} ~ {{to}}
    </div>
</div>

<div class="col-xs-8">
    <div class="dataTables_paginate paging_simple_numbers" id="dynamic-table_paginate">
        <ul class="pagination">
            <li class="paginate_button previous {{^firstUrl}}disabled{{/firstUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="1" data-url="{{firstUrl}}" class="page-action3">首页</a>
            </li>
            <li class="paginate_button {{^beforeUrl}}disabled{{/beforeUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="{{beforePageNo}}" data-url="{{beforeUrl}}" class="page-action3"><<</a>
            </li>
            <li class="paginate_button active" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-id="{{pageNo}}" >第{{pageNo}}页</a>
                <input type="hidden" class="pageNo" value="{{pageNo}}" />
            </li>
            <li class="paginate_button {{^nextUrl}}disabled{{/nextUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="{{nextPageNo}}" data-url="{{nextUrl}}" class="page-action3">>></a>
            </li>
            <li class="paginate_button next {{^lastUrl}}disabled{{/lastUrl}}" aria-controls="dynamic-table" tabindex="0">
                <a href="#" data-target="{{maxPageNo}}" data-url="{{lastUrl}}" class="page-action3">尾页</a>
            </li>
        </ul>
    </div>
</div>

</script>


<script type="text/javascript">
    $(function () {


        $('#datetimepicker1').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn')
        });

        $('#datetimepicker2').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn')
        });

        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDateT = date.getDate();
        var strDateF = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDateT >= 0 && strDateT <= 9) {
            strDateT = "0" + strDateT;
        }
        if (strDateF >= 0 && strDateF <= 9) {
            strDateF = "0" + strDateF;
        }

        //给输入框赋初值
        $('#search-from').val(year+'-'+month+'-'+strDateF);
        $('#search-to').val(year+'-'+month+'-'+strDateT);

        var SendProUnitListTemplate = $('#SendProUnitListTemplate').html();
        Mustache.parse(SendProUnitListTemplate);
        var WeighTruckListTemplate = $('#WeighTruckListTemplate').html();
        Mustache.parse(WeighTruckListTemplate);
        var WeighStorageListTemplate = $('#WeighStorageListTemplate').html();
        Mustache.parse(WeighStorageListTemplate);
        var WeighNameListTemplate = $('#WeighNameListTemplate').html();
        Mustache.parse(WeighNameListTemplate);

        loadSendProUnitList();
        loadWeighTruckList();
        loadWeighStorageList();
        loadWeighNameList();



        $(".research").click(function (e) {
            e.preventDefault();
            $("#SOCPage.pageNo").val('1');
            $("#STOTruckPage.pageNo").val('1');
            $("#WCStoragePage.pageNo").val('1');
            $("#WCNamePage.pageNo").val('1');
            loadSendProUnitList();
            loadWeighTruckList();
            loadWeighStorageList();
            loadWeighNameList();
        });


        //按供货单位
        function loadSendProUnitList() {

            var pageNo = $("#SOCPage.pageNo").val() || 1;
            var fromTime = $("#search-from").val();
            var toTime = $("#search-to").val();
            var url = "/sys/WeighCount/ProUnitPage.json";
            var jbzCode = $("#jbzCode").val();
            $.ajax({
                url: url,
                data: {
                    pageNo: pageNo,
                    pageSize: 5,
                    fromTime: fromTime,
                    toTime: toTime,
                    jbzCode: jbzCode
                },
                type: 'post',
                success: function (result) {
                    console.log("success");
                    renderSendProUnitListAndPage(result, url);
                }
            });
        }

        function renderSendProUnitListAndPage(result, url) {
            if (result.ret) {
                if (result.data.total > 0) {
                    var rendered = Mustache.render(SendProUnitListTemplate, {
                        "SendProUnitList": result.data.data,
                    });
                    $('#SendProUnitList').html(rendered);
                    // $.each(result.data.data, function (i, SendCustomer) {
                    //     stRwdMap[stRwd.id] = SendCustomer;
                    // });
                } else {
                    $('#SendProUnitList').html('');
                }
                var pageNo = $("#SOCPage .pageNo").val() || 1;
                renderPage(url, result.data.total, pageNo, 5, result.data.total > 0 ? result.data.data.length : 0, "SOCPage", renderSendProUnitListAndPage);
            } else {
                showMessage("获取操作列表", result.msg, false);
            }
        };

        // 车牌号
        function loadWeighTruckList() {
            var pageNo = $("#STOTruckPage.pageNo").val() || 1;
            var fromTime = $("#search-from").val();
            var toTime = $("#search-to").val();
            var url = "/sys/WeighCount/TruckPage.json";
            var jbzCode = $("#jbzCode").val();
            $.ajax({
                url: url,
                data: {
                    pageNo: pageNo,
                    pageSize: 5,
                    fromTime: fromTime,
                    toTime: toTime,
                    jbzCode: jbzCode
                },
                type: 'post',
                success: function (result) {
                    console.log("success");
                    renderWeighTruckListAndPage(result, url);
                }
            });
        };

        function renderWeighTruckListAndPage(result, url) {
            if (result.ret) {
                if (result.data.total > 0) {
                    var rendered = Mustache.render(WeighTruckListTemplate, {
                        "WeighTruckList": result.data.data,
                    });
                    $('#WeighTruckList').html(rendered);
                    // $.each(result.data.data, function (i, SendCustomer) {
                    //     stRwdMap[stRwd.id] = SendCustomer;
                    // });
                } else {
                    $('#WeighTruckList').html('');
                }
                var pageNo = $("#WeighTruckPage .pageNo").val() || 1;
                renderPage1(url, result.data.total, pageNo, 5, result.data.total > 0 ? result.data.data.length : 0, "WeighTruckPage", renderWeighTruckListAndPage);
            } else {
                showMessage("获取操作列表", result.msg, false);
            }
        };

        //存放位置
        function loadWeighStorageList() {
            var pageNo = $("#WCStoragePage.pageNo").val() || 1;
            var fromTime = $("#search-from").val();
            var toTime = $("#search-to").val();
            var url = "/sys/WeighCount/StoragePage.json";
            var jbzCode = $("#jbzCode").val();
            $.ajax({
                url: url,
                data: {
                    pageNo: pageNo,
                    pageSize: 5,
                    fromTime: fromTime,
                    toTime: toTime,
                    jbzCode: jbzCode
                },
                type: 'post',
                success: function (result) {
                    console.log("success");
                    renderWeighStorageListAndPage(result, url);
                }
            });
        };

        function renderWeighStorageListAndPage(result, url) {
            if (result.ret) {
                if (result.data.total > 0) {
                    var rendered = Mustache.render(WeighStorageListTemplate, {
                        "WeighStorageList": result.data.data,
                    });
                    $('#WeighStorageList').html(rendered);
                    // $.each(result.data.data, function (i, SendCustomer) {
                    //     stRwdMap[stRwd.id] = SendCustomer;
                    // });
                } else {
                    $('#WeighStorageList').html('');
                }
                var pageNo = $("#WCStoragePage .pageNo").val() || 1;
                renderPage2(url, result.data.total, pageNo, 5, result.data.total > 0 ? result.data.data.length : 0, "WCStoragePage", renderWeighStorageListAndPage);
            } else {
                showMessage("获取操作列表", result.msg, false);
            }
        };

        //货物名称
        function loadWeighNameList() {
            var pageNo = $("#WCNamePage.pageNo").val() || 1;
            var fromTime = $("#search-from").val();
            var toTime = $("#search-to").val();
            var url = "/sys/WeighCount/NamePage.json";
            var jbzCode = $("#jbzCode").val();
            $.ajax({
                url: url,
                data: {
                    pageNo: pageNo,
                    pageSize: 5,
                    fromTime: fromTime,
                    toTime: toTime,
                    jbzCode: jbzCode
                },
                type: 'post',
                success: function (result) {
                    console.log("success");
                    renderWeighNameListAndPage(result, url);
                }
            });
        };

        function renderWeighNameListAndPage(result, url) {
            if (result.ret) {
                if (result.data.total > 0) {
                    var rendered = Mustache.render(WeighNameListTemplate, {
                        "WeighNameList": result.data.data,
                    });
                    $('#WeighNameList').html(rendered);
                } else {
                    $('#WeighNameList').html('');
                }
                var pageNo = $("#WCNamePage .pageNo").val() || 1;
                renderPage3(url, result.data.total, pageNo, 5, result.data.total > 0 ? result.data.data.length : 0, "WCNamePage", renderWeighNameListAndPage);
            } else {
                showMessage("获取操作列表", result.msg, false);
            }
        };


        var paginateTemplate = $("#paginateTemplate").html();
        Mustache.parse(paginateTemplate);

        function renderPage(url, total, pageNo, pageSize, currentSize, idElement, callback) {
            var maxPageNo = Math.ceil(total / pageSize);
            var paramStartChar = url.indexOf("?") > 0 ? "&" : "?";
            var from = (pageNo - 1) * pageSize + 1;
            var view = {
                from: from > total ? total : from,
                to: (from + currentSize - 1) > total ? total : (from + currentSize - 1),
                total: total,
                pageNo: Number(pageNo),
                maxPageNo: maxPageNo,
                nextPageNo: Number(pageNo) >= maxPageNo ? maxPageNo : (Number(pageNo) + 1),
                beforePageNo: pageNo == 1 ? 1 : (pageNo - 1),
                firstUrl: (pageNo == 1) ? '' : (url + paramStartChar + "pageNo=1&pageSize=" + pageSize),
                beforeUrl: (pageNo == 1) ? '' : (url + paramStartChar + "pageNo=" + (Number(pageNo) - 1) + "&pageSize=" + pageSize),
                nextUrl: (pageNo >= maxPageNo) ? '' : (url + paramStartChar + "pageNo=" + (Number(pageNo) + 1) + "&pageSize=" + pageSize),
                lastUrl: (pageNo >= maxPageNo) ? '' : (url + paramStartChar + "pageNo=" + maxPageNo + "&pageSize=" + pageSize)
            };
            $("#" + idElement).html(Mustache.render(paginateTemplate, view));

            $(".page-action").click(function (e) {
                e.preventDefault();
                $("#" + idElement + " .pageNo").val($(this).attr("data-target"));
                var targetUrl = $(this).attr("data-url");
                var fromTime = $("#search-from").val();
                var toTime = $("#search-to").val();
                if (targetUrl != '') {
                    $.ajax({
                        url: targetUrl,
                        data: {
                            fromTime: fromTime,
                            toTime: toTime,
                        },
                        type: 'post',
                        success: function (result) {
                            if (callback) {
                                callback(result, url);
                            }
                        }
                    })
                }
            })
        }

        var paginateTemplate1 = $("#paginateTemplate1").html();
        Mustache.parse(paginateTemplate1);

        function renderPage1(url, total, pageNo, pageSize, currentSize, idElement, callback) {
            var maxPageNo = Math.ceil(total / pageSize);
            var paramStartChar = url.indexOf("?") > 0 ? "&" : "?";
            var from = (pageNo - 1) * pageSize + 1;
            var view = {
                from: from > total ? total : from,
                to: (from + currentSize - 1) > total ? total : (from + currentSize - 1),
                total: total,
                pageNo: Number(pageNo),
                maxPageNo: maxPageNo,
                nextPageNo: Number(pageNo) >= maxPageNo ? maxPageNo : (Number(pageNo) + 1),
                beforePageNo: pageNo == 1 ? 1 : (pageNo - 1),
                firstUrl: (pageNo == 1) ? '' : (url + paramStartChar + "pageNo=1&pageSize=" + pageSize),
                beforeUrl: (pageNo == 1) ? '' : (url + paramStartChar + "pageNo=" + (Number(pageNo) - 1) + "&pageSize=" + pageSize),
                nextUrl: (pageNo >= maxPageNo) ? '' : (url + paramStartChar + "pageNo=" + (Number(pageNo) + 1) + "&pageSize=" + pageSize),
                lastUrl: (pageNo >= maxPageNo) ? '' : (url + paramStartChar + "pageNo=" + maxPageNo + "&pageSize=" + pageSize)
            };
            $("#" + idElement).html(Mustache.render(paginateTemplate1, view));

            $(".page-action1").click(function (e) {
                e.preventDefault();
                $("#" + idElement + " .pageNo").val($(this).attr("data-target"));
                var targetUrl = $(this).attr("data-url");
                var fromTime = $("#search-from").val();
                var toTime = $("#search-to").val();
                if (targetUrl != '') {
                    $.ajax({
                        url: targetUrl,
                        data: {
                            fromTime: fromTime,
                            toTime: toTime,
                        },
                        type: 'post',
                        success: function (result) {
                            if (callback) {
                                callback(result, url);
                            }
                        }
                    })
                }
            })
        }


        var paginateTemplate2 = $("#paginateTemplate2").html();
        Mustache.parse(paginateTemplate1);

        function renderPage2(url, total, pageNo, pageSize, currentSize, idElement, callback) {
            var maxPageNo = Math.ceil(total / pageSize);
            var paramStartChar = url.indexOf("?") > 0 ? "&" : "?";
            var from = (pageNo - 1) * pageSize + 1;
            var view = {
                from: from > total ? total : from,
                to: (from + currentSize - 1) > total ? total : (from + currentSize - 1),
                total: total,
                pageNo: Number(pageNo),
                maxPageNo: maxPageNo,
                nextPageNo: Number(pageNo) >= maxPageNo ? maxPageNo : (Number(pageNo) + 1),
                beforePageNo: pageNo == 1 ? 1 : (pageNo - 1),
                firstUrl: (pageNo == 1) ? '' : (url + paramStartChar + "pageNo=1&pageSize=" + pageSize),
                beforeUrl: (pageNo == 1) ? '' : (url + paramStartChar + "pageNo=" + (Number(pageNo) - 1) + "&pageSize=" + pageSize),
                nextUrl: (pageNo >= maxPageNo) ? '' : (url + paramStartChar + "pageNo=" + (Number(pageNo) + 1) + "&pageSize=" + pageSize),
                lastUrl: (pageNo >= maxPageNo) ? '' : (url + paramStartChar + "pageNo=" + maxPageNo + "&pageSize=" + pageSize)
            };
            $("#" + idElement).html(Mustache.render(paginateTemplate2, view));

            $(".page-action2").click(function (e) {
                e.preventDefault();
                $("#" + idElement + " .pageNo").val($(this).attr("data-target"));
                var targetUrl = $(this).attr("data-url");
                var fromTime = $("#search-from").val();
                var toTime = $("#search-to").val();
                if (targetUrl != '') {
                    $.ajax({
                        url: targetUrl,
                        data: {
                            fromTime: fromTime,
                            toTime: toTime,
                        },
                        type: 'post',
                        success: function (result) {
                            if (callback) {
                                callback(result, url);
                            }
                        }
                    })
                }
            })
        }

        var paginateTemplate3 = $("#paginateTemplate3").html();
        Mustache.parse(paginateTemplate3);

        function renderPage3(url, total, pageNo, pageSize, currentSize, idElement, callback) {
            var maxPageNo = Math.ceil(total / pageSize);
            var paramStartChar = url.indexOf("?") > 0 ? "&" : "?";
            var from = (pageNo - 1) * pageSize + 1;
            var view = {
                from: from > total ? total : from,
                to: (from + currentSize - 1) > total ? total : (from + currentSize - 1),
                total: total,
                pageNo: Number(pageNo),
                maxPageNo: maxPageNo,
                nextPageNo: Number(pageNo) >= maxPageNo ? maxPageNo : (Number(pageNo) + 1),
                beforePageNo: pageNo == 1 ? 1 : (pageNo - 1),
                firstUrl: (pageNo == 1) ? '' : (url + paramStartChar + "pageNo=1&pageSize=" + pageSize),
                beforeUrl: (pageNo == 1) ? '' : (url + paramStartChar + "pageNo=" + (Number(pageNo) - 1) + "&pageSize=" + pageSize),
                nextUrl: (pageNo >= maxPageNo) ? '' : (url + paramStartChar + "pageNo=" + (Number(pageNo) + 1) + "&pageSize=" + pageSize),
                lastUrl: (pageNo >= maxPageNo) ? '' : (url + paramStartChar + "pageNo=" + maxPageNo + "&pageSize=" + pageSize)
            };
            $("#" + idElement).html(Mustache.render(paginateTemplate3, view));

            $(".page-action3").click(function (e) {
                e.preventDefault();
                $("#" + idElement + " .pageNo").val($(this).attr("data-target"));
                var targetUrl = $(this).attr("data-url");
                var fromTime = $("#search-from").val();
                var toTime = $("#search-to").val();
                if (targetUrl != '') {
                    $.ajax({
                        url: targetUrl,
                        data: {
                            fromTime: fromTime,
                            toTime: toTime,
                        },
                        type: 'post',
                        success: function (result) {
                            if (callback) {
                                callback(result, url);
                            }
                        }
                    })
                }
            })
        }

        $("[data-toggle='tooltip']").tooltip();
    });

    $(function () {
        $("[data-toggle='tooltip']").tooltip();
    });

    jQuery(function($) {

        $('#simple-colorpicker-1').ace_colorpicker({pull_right:true}).on('change', function(){
            var color_class = $(this).find('option:selected').data('class');
            var new_class = 'widget-header';
            if(color_class != 'default')  new_class += ' header-color-'+color_class;
            $(this).closest('.widget-header').attr('class', new_class);
        });

        $('#simple-colorpicker-2').ace_colorpicker({pull_right:true}).on('change', function(){
            var color_class = $(this).find('option:selected').data('class');
            var new_class = 'widget-header';
            if(color_class != 'default')  new_class += ' header-color-'+color_class;
            $(this).closest('.widget-header').attr('class', new_class);
        });

        // scrollables
        $('.slim-scroll').each(function () {
            var $this = $(this);
            $this.slimScroll({
                height: $this.data('height') || 100,
                railVisible:true
            });
        });

        // Portlets (boxes)
        $('.widget-container-span').sortable({
            connectWith: '.widget-container-span',
            items:'> .widget-box',
            opacity:0.8,
            revert:true,
            forceHelperSize:true,
            placeholder: 'widget-placeholder',
            forcePlaceholderSize:true,
            tolerance:'pointer'
        });

    });
</script>

</body>
</html>
